/**
 * 
 */
package cn.biplam.front.template.base;

import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.front.html.HtmlDiv;
import cn.biplam.front.html.HtmlImage;
import cn.biplam.front.html.base.HtmlWindow;
import cn.biplam.front.html.base.Const.Window_Event;
import cn.biplam.front.template.Template;

/**
 * 占满按钮大小的小型图片按钮(用于标题区)
 * @author 	WangSong
 * @create 	2009-4-10 下午05:28:56
 * @version 1.0
 */
public class ButtonImageSwitch implements Template{
	
	private HtmlDiv button;
	private String id;
	private String imageUrl;
	private String imageUrlShow;
	private String imageCssId;
	
	/**
	 * 构造方法
	 * @param ID		页面ID
	 * @param imageUrl	按钮图片
	 */
	public ButtonImageSwitch(String id,String imageUrl){
		this.id=id;
		this.imageUrl=imageUrl;
	}
	
	/**
	 * 构造方法
	 * @param ID		页面ID
	 * @param imageUrl	按钮图片
	 * @param imageUrlShow	鼠标移动到时按钮图片
	 */
	public ButtonImageSwitch(String id,String imageUrl,String imageUrlShow){
		this.id=id;
		this.imageUrl=imageUrl;
		this.imageUrlShow=imageUrlShow;
	}
	
	public void setImageCss(String cssID){
		this.imageCssId=cssID;
	}

	/**
	 * 返回设置好的Html控件
	 */
	public HtmlWindow get() throws ErrorMessage{
		String cssID=this.imageCssId!=null?this.imageCssId:"sipi";
		this.button=new HtmlDiv(this.id,cssID);
		
		HtmlImage image=new HtmlImage(imageUrl);
		
		if(this.imageUrlShow!=null){
			image.bind(Window_Event.OnmouseOver, "this.src='"+imageUrlShow+"';");
			image.bind(Window_Event.OnMouseOut, "this.src='"+imageUrl+"';");
		}
		
		this.button.put(image);
		return this.button;
	}




}
